#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

bool is_prime(ll x) {
    if (x < 2) return false;
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    int maxn=INT_MIN;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i]>maxn)maxn=a[i];
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll candd = maxn + 1;
    while (!is_prime(candd)) {
        candd++;
    }
    bool valid = true;
    for (int i = 0; i < n; i++) {
        if (candd % a[i] == 0 || a[i] % candd == 0) {
            valid = false;
            break;
        }
    }

    if (valid && candd <= 1000000000000000000LL) {
        cout << candd << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}